﻿using System;

namespace Hanoi
{
    class Program
    {
        static int Count = 1;
        static void Hanio ( int n , string A, string B, string C )
        {
            if (n > 0)
                {
                    Hanio(n - 1, A, C, B);   //函数递归调用
                    Console.WriteLine( "第" + Count++ + "步：" + n + "从" + A + "到" + C);
                    Hanio(n - 1, B, A, C);
                }
        }
        static void Main(string[] args)
        {
            Console.WriteLine("请输入层数：");
            int N = Convert.ToInt32(Console.ReadLine());
            Hanio(N,"A","B","C");
            Console.WriteLine("一共{0}步", Count - 1);
        }
    }
}
